import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:provider/provider.dart';
import 'package:s_k_todo/provider/home_provider.dart';
import 'package:s_k_todo/provider/task_list.dart';
import 'package:s_k_todo/provider/user_provider.dart';
import 'package:s_k_todo/ui/home_page.dart';
import 'package:s_k_todo/ui/login_page.dart';

final routerConfig = GoRouter(routes: [
  GoRoute(
    path: '/',
    pageBuilder: (context, state) {
      return MaterialPage<void>(
        key: state.pageKey,
        child: ChangeNotifierProvider(
          create: (_) => UserProvider(),
          builder: (_, _1) => const LoginPage(),
        ),
      );
    },
  ),
  GoRoute(
      path: "/home",
      pageBuilder: (ctx, state) => MaterialPage<void>(
          key: state.pageKey,
          child: MultiProvider(
            providers: [
              ChangeNotifierProvider(
                create: (_) => TaskListProvider(),
              ),
              ChangeNotifierProvider(
                create: (_) => HomeProvider(),
              ),
            ],
            builder: (_, _1) => const HomePage(),
          )))
]);
